define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'com.coupon/index',
        add_url: 'com.coupon/add',
        edit_url: 'com.coupon/edit',
        delete_url: 'com.coupon/delete',
        export_url: 'com.coupon/export',
        modify_url: 'com.coupon/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},                    {field: 'id', title: '优惠卷ID'},                    {field: 'user_id', title: 'user_id'},                    {field: 'name', title: '优惠卷名称'},                    {field: 'condition', title: '使用条件'},                    {field: 'type', title: '0-立减劵 1-折扣卷'},                    {field: 'discount', title: '折扣'},                    {field: 'count', title: '0-可随意使用 1-仅能用一张 2-以此类推'},                    {field: 'belong', title: '0-平台 1-商家 2-商品'},                    {field: 'sotre_id', title: '门店ID'},                    {field: 'goods_id', title: '商品ID'},                    {field: 'state', title: '0-正常使用 1-已过期 2-已禁用'},                    {field: 'starttime', title: 'starttime'},                    {field: 'endtime', title: 'endtime'},                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});